using System.Linq;
using UnityEngine;
using WolfCarol.AvgToolkit.Save;

namespace WolfCarol.AvgToolkit.Examples
{
    public class AudioPresenter : MonoBehaviour, ISavable<AudioData[]>
    {
        [SerializeField] private StageAudio[] m_sources;

        public void Clear()
        {
            foreach (var source in m_sources)
            {
                source.Clear();
            }
        }

        public AudioData[] Save()
        {
            return m_sources.Select(source => source.Save()).ToArray();
        }

        public void Load(AudioData[] obj)
        {
            for (int i = 0; i < m_sources.Length; i++)
            {
                m_sources[i].Load(obj[i]);
            }
        }
    }
}